package com.wakala.employment.fragment.other;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.amap.api.maps2d.AMap;
import com.amap.api.maps2d.MapView;
import com.amap.api.maps2d.MapsInitializer;
import com.amap.api.maps2d.model.CameraPosition;
import com.amap.api.maps2d.model.LatLng;
import com.leaf.library.StatusBarUtil;
import com.wakala.employment.R;
import com.wakala.employment.core.BaseFragment;
import com.wakala.employment.databinding.FragmentGdMapBinding;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.actionbar.TitleBar;

/**
 * A simple {@link Fragment} subclass.
 * Use the {@link GdMapFragment#} factory method to
 * create an instance of this fragment.
 */
@Page(anim = CoreAnim.none)
public class GdMapFragment extends BaseFragment<FragmentGdMapBinding> implements View.OnClickListener {
    private String TAG = "JobCategoryFragment";

    private AMap aMap;
    private MapView mapView;
    private final static LatLng SYDNEY = new LatLng(-33.86759, 151.2088);
    private final static LatLng BEIJING = new LatLng(39.8965, 116.4074);



    @NonNull
    @Override
    protected FragmentGdMapBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentGdMapBinding.inflate(inflater, container, attachToRoot);
    }

    /**
     * @return 返回为 null意为不需要导航栏
     */
    @Override
    protected TitleBar initTitle() {
        TitleBar titleBar = super.initTitle();
        titleBar.setTitle("地址选择");
        titleBar.setTitleColor(R.color.black);
        titleBar.setLeftTextColor(R.color.black);
        titleBar.setLeftImageDrawable(getResources().getDrawable(R.drawable.icon_arrow_back));
        titleBar.setBackgroundResource(R.color.white);//设置标题栏背景颜色
        StatusBarUtil.setDarkMode(getActivity());

        //设置状态栏背景颜色，如果设置为 Color.TRANSPARENT 将会隐藏状态栏
        getActivity().getWindow().setStatusBarColor(getResources().getColor(R.color.white));
        return titleBar;
    }


    @Override
    protected void initViews() {
        mapView = (MapView) findViewById(R.id.map);
        //初始化地图控制器对象
        initMap();
    }

    /**
     * 初始化AMap对象
     */
    private void initMap() {
        if (aMap == null) {
            aMap = mapView.getMap();

            setUpMap();
        }
    }
    /**
     * 对地图添加onMapIsAbroadListener
     */
    private void setUpMap() {
        aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() {

            @Override
            public void onCameraChangeFinish(CameraPosition cameraPosition) {

            }

            @Override
            public void onCameraChange(CameraPosition cameraPosition) {
            }
        });
    }


    @Override
    public void onClick(View view) {

    }
}